import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class CalendarSeeker {
	public enum WeekDay {SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
	public static void main (String[] args) throws NumberFormatException, IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		int d=1, m=1, y=1;
		int monthType; // Can be 28, 29, 30, 31
		boolean isWrongInput=true;
		while (isWrongInput) {
			try {
				isWrongInput=false;
				System.out.println("Enter date.");
				System.out.print("Enter month (mm):");
				m = Integer.parseInt(input.readLine());
				
				if ((m>12)||(m<1)) { // month input verification
					isWrongInput = true;
					System.out.println("Wrong input. Month should be from 1 to 12.");
					continue;
				}
				System.out.print("Enter year (yyyy):");
				y = Integer.parseInt(input.readLine());
				System.out.print("Enter day (dd):");
				d = Integer.parseInt(input.readLine());
				
				monthType = monthToDays(m,y); 
				if ((d<1)||(d>monthType)) { // Day input verification
					isWrongInput = true;
					System.out.println("Wrong input. From 1 to "+monthType+" days, please.");
					continue;
				}
				System.out.println("Your date is (dd.mm.yyyy): "+d+"."+m+"."+y);
			}
			catch (NumberFormatException e) { // Nothing but numbers are accepted
				isWrongInput = true;
				System.out.println("Wrong input. Enter numbers only.");
			}
		}
		int dDiff=0, mDiff=0, yDiff = 0, totalDiff = 0;
		
		// calculate difference between inputed year and zero point (in days)
		if (y>2013) { 
			for (int i=2014; i<=y; i++) {
				yDiff+=yearToDays(i);
			}	
		} else if (y<2013) { 
			for (int i=2012; i>=y; i--) {
				yDiff-=yearToDays(i+1);
			}
		} else {
			yDiff=0;
		}
		// calculate difference between inputed month and zero point (in days)
		if (m>10) { 
			for (int i=11; i<=m; i++) {
				mDiff+=monthToDays(i-1, y);
			}	
		} else if (m<10) { 
			for (int i=9; i>=m; i--) {
				mDiff-=monthToDays(i, y);
			}
		} else {
			mDiff=0;
		}
		
		dDiff=d-23; // calculate difference between inputed day and zero point (in days)
		totalDiff=dDiff+mDiff+yDiff; // calculate total difference between inputed date and zero point (in days)
		
		int weekdayInt = totalDiff%7; // remainder calculation 
		String weekdayString = null;
		switch (weekdayInt) {
		case 4: case -3: weekdayString = "SUNDAY";break;
		case 5: case -2: weekdayString = "MONDAY";break;
		case 6: case -1: weekdayString = "TUESDAY";break;
		case 0: 		 weekdayString = "WEDNESDAY";break; // 23.10.2013 (The Zero point) is Wednesday
		case 1: case -6: weekdayString = "THURSDAY";break;
		case 2: case -5: weekdayString = "FRIDAY";break;
		case 3: case -4: weekdayString = "SATURDAY";break;
		}
		System.out.println("Weekday is: "+weekdayString);
		
	}
	// can be 365 or 366 days in a year
	private static int yearToDays (int y) {
		if ((y%4==0)&&(y%100!=0)||(y%400==0)) {  // intercalary year verification 
			y=366;
		} else {y=365;}
		return y;
	}
	// can be 28,29,30,31 days in a month
	private static int monthToDays (int m, int y) { 
		switch (m) {
		case 2: if ((y%4==0)&&(y%100!=0)||(y%400==0)) { // intercalary year verification
			m = 29;	
		} 	else {m = 28;}
		break;
		case 1: case 3: case 5: case 7: case 8: case 10: case 12:m = 31; break;
		case 4: case 6: case 9: case 11: m = 30; break;
		}
		return m;
	}
}